home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / utils / file / logiso.000 / logiso / Utils / RCS / install_list,v < prev    next >
Encoding:
Text File  |  1995-03-24  |  4.8 KB  |  245 lines

  1. head    1.6;
  2. access;
  3. symbols
  4.     VER_0_3:1.6
  5.     VER_0_2:1.5;
  6. locks; strict;
  7. comment    @# @;
  8.  
  9.  
  10. 1.6
  11. date    95.03.24.11.43.35;    author coulter;    state Exp;
  12. branches;
  13. next    1.5;
  14.  
  15. 1.5
  16. date    95.03.10.02.42.22;    author coulter;    state Exp;
  17. branches;
  18. next    1.4;
  19.  
  20. 1.4
  21. date    95.02.19.17.13.08;    author coulter;    state Exp;
  22. branches;
  23. next    1.3;
  24.  
  25. 1.3
  26. date    95.02.19.16.06.41;    author coulter;    state Exp;
  27. branches;
  28. next    1.2;
  29.  
  30. 1.2
  31. date    95.02.18.08.36.38;    author coulter;    state Exp;
  32. branches;
  33. next    1.1;
  34.  
  35. 1.1
  36. date    95.02.12.18.21.15;    author coulter;    state Exp;
  37. branches;
  38. next    ;
  39.  
  40.  
  41. desc
  42. @Install the files in the list produced by process_list.
  43. @
  44.  
  45.  
  46. 1.6
  47. log
  48. @Checkin version for 0.3 distribution.
  49. @
  50. text
  51. @#! /bin/ksh
  52. USAGE='USAGE: install_list [ -d config_prefix ] list_file mount_path map_to_path
  53.     Each line of list_file has an inode number followed by two tabs and
  54.     a file path.  Each file path starts with the string passed in 
  55.     the mount_path argument.  The file or directory is installed
  56.     at the path formed by replacing mount_path with map_to_path.
  57.  
  58.     If a file or directory is listed and its parent directory needs
  59.     to be installed, the parent directory must be in list_file also.
  60. '
  61. # (C) Copyright 1995 by Michael Coulter.  All rights reserved.
  62.  
  63. # define functions
  64.  
  65. # Process parameters
  66.  
  67.    ##echo "install_list: command: $0 $*"
  68.    CONFIG_PREFIX=""
  69.    if [ $# -ge 2 -a "$1" = "-d" ]
  70.    then
  71.       shift  # done with -d
  72.       CONFIG_PREFIX="$1"; shift
  73.    fi
  74.    if [ $# -ne 3 ]
  75.    then
  76.       echo "$USAGE" >&2
  77.       echo "$0 Expected 3 arguments, got $#" >&2
  78.       exit 1
  79.    fi
  80.    LIST_FILE="$1"; shift
  81.    if [ ! -r "$LIST_FILE" ] 
  82.    then
  83.       echo "$USAGE" >&2
  84.       echo "Unable to read list_file, $LIST_FILE" >&2
  85.       exit 1
  86.    fi
  87.    MOUNT_PATH="$1"; shift
  88.    if [ ! -d "$MOUNT_PATH" ] 
  89.    then
  90.       echo "$USAGE" >&2
  91.       echo "No directory at MOUNT_PATH, $MOUNT_PATH" >&2
  92.       exit 1
  93.    fi
  94.    MAP_TO_PATH="$1"; shift
  95.    if [ ! -d "$MAP_TO_PATH" ] 
  96.    then
  97.       echo "$USAGE" >&2
  98.       echo "No directory at MAP_TO_PATH, $MAP_TO_PATH" >&2
  99.       exit 1
  100.    fi
  101.  
  102. # Do it
  103.  
  104.  
  105.    ##echo "install_list: MOUNT_PATH is $MOUNT_PATH MAP_TO_PATH $MAP_TO_PATH"
  106.    cut -f3 "$LIST_FILE" | sort | while read FILE_PATH
  107.    do
  108.       echo "$FILE_PATH"
  109.       if [ "$FILE_PATH" = "${FILE_PATH#$MOUNT_PATH}" ]
  110.       then
  111.          if [ "$FILE_PATH" != '.' ]
  112.          then
  113.         echo "$FILE_PATH is not below $MOUNT_PATH" >&2
  114.          fi
  115.          continue
  116.       fi
  117.       if [ "$FILE_PATH" = "$MOUNT_PATH" ]
  118.       then
  119.          continue # can't install at this level
  120.       fi
  121.       if [ -d "$FILE_PATH" ]
  122.       then
  123.      FILE_DIR="$FILE_PATH"
  124.       else
  125.      FILE_DIR="$(dirname "$FILE_PATH")"
  126.       fi
  127.       if [ "$MAP_TO_PATH" = "/" ]
  128.       then
  129.      DEST_FILE="${FILE_PATH#$MOUNT_PATH}"
  130.       else
  131.      DEST_FILE="${MAP_TO_PATH}/${FILE_PATH#$MOUNT_PATH}"
  132.       fi
  133.  
  134.       ##echo "install_list: DEST_FILE is $DEST_FILE"
  135.       ##echo install_list: install_dir -d "$CONFIG_PREFIX" "$(dirname "$DEST_FILE")" "$MOUNT_PATH" "$MAP_TO_PATH"
  136.       install_dir -d "$CONFIG_PREFIX" "$(dirname "$DEST_FILE")" "$MOUNT_PATH" "$MAP_TO_PATH"
  137.       if [ -f "$FILE_PATH" ]
  138.       then
  139.          if [ -L "$DEST_FILE" ]
  140.          then
  141.         rm "$DEST_FILE"
  142.          fi
  143.          if [ -f "$DEST_FILE" ]
  144.          then
  145.             echo "$DEST_FILE is already a file"
  146.          else
  147.         cp "${FILE_PATH}" "$DEST_FILE"
  148.  
  149.         # Kludge, map in a .el when .elc is mapped in.
  150.         ##echo "install_list: FILE_PATH is '$FILE_PATH'"
  151.         if [ "$FILE_PATH" != "${FILE_PATH%.elc}" ]
  152.         then
  153.            EL_FILE="${FILE_PATH%.elc}.el"
  154.            ##echo "install_list: EL_FILE is '$EL_FILE'"
  155.            if [ -f "$EL_FILE" -a -L "${DEST_FILE%.elc}.el" ]
  156.            then
  157.               rm "${DEST_FILE%.elc}.el"
  158.               cp "$EL_FILE" "${DEST_FILE%.elc}.el"
  159.            fi
  160.         fi
  161.          fi
  162.       else
  163.          if [ ! -d "$FILE_PATH" ]
  164.          then
  165.         echo "$FILE_PATH is not a file or directory!" >&2
  166.         continue
  167.          fi
  168.          if [ -L "$DEST_FILE" ]
  169.          then
  170.         install_dir -d "$CONFIG_PREFIX" "$DEST_FILE" "$MOUNT_PATH" "$MAP_TO_PATH"
  171.          fi
  172.       fi
  173.    done
  174. @
  175.  
  176.  
  177. 1.5
  178. log
  179. @Checkin files modified to make version 0.2
  180. @
  181. text
  182. @d11 1
  183. @
  184.  
  185.  
  186. 1.4
  187. log
  188. @Add kludge for .el files.
  189. @
  190. text
  191. @d2 1
  192. a2 1
  193. USAGE='USAGE: install_list list_file mount_path map_to_path
  194. d16 7
  195. d54 1
  196. d83 3
  197. a85 1
  198.       install_dir "$(dirname "$DEST_FILE")" "$MOUNT_PATH" "$MAP_TO_PATH"
  199. d99 1
  200. d102 7
  201. a108 5
  202.           EL_FILE="${FILE_PATH%.elc}.el"
  203.           if [ -f "$EL_FILE" -a -L "$EL_FILE" ]
  204.           then
  205.              install_list "$EL_FILE" "$MOUNT_PATH" "$MAP_TO_PATH"
  206.           fi
  207. d119 1
  208. a119 1
  209.         install_dir "$DEST_FILE" "$MOUNT_PATH" "$MAP_TO_PATH"
  210. @
  211.  
  212.  
  213. 1.3
  214. log
  215. @Checkpoint version 0.1
  216. @
  217. text
  218. @d87 10
  219. @
  220.  
  221.  
  222. 1.2
  223. log
  224. @Checkpoint version before fixing /usr/bin install
  225. @
  226. text
  227. @d58 4
  228. d74 1
  229. @
  230.  
  231.  
  232. 1.1
  233. log
  234. @Initial revision
  235. @
  236. text
  237. @d49 1
  238. a49 1
  239.       echo "install_list: $FILE_PATH"
  240. d52 4
  241. a55 1
  242.          echo "$FILE_PATH is not below $MOUNT_PATH" >&2
  243. d82 10
  244. @
  245.